package com.research.web.task;

import com.alibaba.druid.pool.DruidDataSource;
import com.research.web.utils.UserSynchronizeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class UserTimerSynchronizeTask {
    @Autowired
    private List<DruidDataSource> dataSourceList;

    /*** 定时器定时同步所有数据信息 ****/
    //    @Scheduled(cron = "0 0 0 */1 * ?")
//    @Scheduled(cron = "*/5 * * * * ?")
    public void userSynchronizeTimer() {
        log.debug("【启动用户服务同步】开始");
        try {
            UserSynchronizeUtils.synchronizeAllUserInfo(dataSourceList);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("【启动用户服务同步】失败");
        }
        log.debug("【启动用户服务同步】结束");
    }

}
